using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Main.lib.input;
using Main.lib.space;

using Main.lib.scene;
using Main.lib.graphics;
using Main.lib.util;

namespace Main
{

    public sealed class Main : Microsoft.Xna.Framework.Game
    {

     // Scope         Type                  Name          Value
        public static GraphicsDeviceManager Video    = null;
        private       SpriteBatch           SpriteBatch = null;
        
        public static Main self;

        public Main()
        {
            Video = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            IsMouseVisible = true;

            Video.PreferredBackBufferWidth  = 640;
            Video.PreferredBackBufferHeight = 480;
            Video.ApplyChanges();
            
            self = this;
        }

        protected override void Initialize()
        {
            base.Initialize();
            Scene.Set(new Scene_Title());
        }

        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);
        }

        protected override void UnloadContent()
        {
            Cache.Clear();
        }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            Input.Update();
            Scene.Update();
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            base.Draw(gameTime);
            SpriteBatch.Begin(SpriteSortMode.FrontToBack, null);
            Graphics.Draw(SpriteBatch);
            SpriteBatch.End();
        }

    }

}